#ifndef H_TEMPLATEMETHOD_MODE_H
#define H_TEMPLATEMETHOD_MODE_H
#include <iostream>
namespace TemplateMethodMode
{
    class AbstractClass
    {
    public:
        void TemplateMethod()
        {
            abstractMethod1();
            if(HookMethod())
            {
                SpecificMethod();
            }
            abstractMethod2();
        }

        void SpecificMethod()
        {
            std::cout<<"抽象类中的具体方法被调用..."<<std::endl;
        }

        virtual bool HookMethod()
        {
            return true;
        }

        virtual void abstractMethod1() = 0;

        virtual void abstractMethod2() = 0;
    };
}

#endif

//TemplateMethodMode::AbstractClass* pTemplateMethod = new TemplateMethodMode::ConcreteClass;
//pTemplateMethod->TemplateMethod();